﻿using HlELock.Core;
using HlELock.Core.Events;
using HlELock.Domain;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using System.Windows;

namespace HlELock.Modules.Hotel.Main.ViewModels
{
    internal class RoomManagementMenuViewModel : MenuViewModel
    {
        public RoomManagementMenuViewModel()
        {
            ClickCommand = new DelegateCommand<string>(ExecuteClickCommand);
        }
        protected override void ExecuteClickCommand(string arg)
        {
            if (arg == "RemoveAll")
            {
                var text = AppHelper.GetResourceString("ShiFuoQueRenChanChuCaoZuo");
                var title = AppHelper.GetResourceString("TiShi");
                if (MessageBox.Show(text, title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    using (var context = new HlELockDbContext())
                    {
                        context.RemoveRange(context.Rooms);
                        context.SaveChanges();
                    }
                }
                EventBus.RefreshRoomList();
            }
            else
            {
                base.ExecuteClickCommand(arg);
            }
        }
    }
}
